﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using ThaoTac;
using ThongTin;
using DuLieu;

namespace GiaoDien
{
    public partial class frmDanhSachMonHoc : Form
    {
        MonHoc_DL mh = new MonHoc_DL();
        public frmDanhSachMonHoc()
        {
            InitializeComponent();
            tblDanhSachMonHoc.DataSource = mh.DanhSachMonHoc();
        }
        //Thêm Ngành Đào Tạo
        public void add(Object sender, EventArgs e)
        {
            frmQuanLyMonHoc tt = (frmQuanLyMonHoc)sender;
            DataTable dt = (DataTable)tblDanhSachMonHoc.DataSource;
            dt.Rows.Add(tt.MaMonHoc, tt.TenMonHoc, tt.SoTinChi);
            tblDanhSachMonHoc.DataSource = dt;
            SqlConnection cnn = new SqlConnection();
            SqlCommand cmd = new SqlCommand("ThemMonHoc", cnn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlCommandBuilder cmb = new SqlCommandBuilder(da);
            da.UpdateCommand = cmb.GetUpdateCommand();
        }
        private void btnThem_Click_1(object sender, EventArgs e)
        {
            frmQuanLyMonHoc tt = new frmQuanLyMonHoc();
            tt.addNew += new EventHandler(add);
            tt.Show(); 
        }


    }
}
